package com.binya.lib.permission.share;

import android.content.Context;
import android.text.TextUtils;

/**
 * @author ydh
 * Time 2023年03月07日
 */
public class ByPermissionSharePreference extends BaseSharePreference {

    private static ByPermissionSharePreference instance;

    public static ByPermissionSharePreference getInstance(Context context) {
        if (instance == null) {
            synchronized (ByPermissionSharePreference.class) {
                if (instance == null) {
                    instance = new ByPermissionSharePreference(context, "by_permission");
                }
            }
        }
        return instance;
    }

    private ByPermissionSharePreference(Context context, String spName) {
        super(context, spName);
    }

    /**
     * 权限请求信息
     */
    public String getPermissionStatus() {
        return get("permission_status", "");
    }

    public void savePermissionStatus(String str) {
        String s = get("permission_status", "");
        if (!TextUtils.isEmpty(s)) {
            if (s.contains(str)) {
                return;
            }
        }
        set("permission_status", s + str);
    }

    public void delPermissionStatus(String str) {
        String s = get("permission_status", "");
        if (!TextUtils.isEmpty(s)) {
            if (s.contains(str)) {
                set("permission_status", s.replace(str, ""));
            }
        }
    }

}